
package ClientRun;

import Client.Client;
import Client.ClientController;
import Client.ClientListner;
import ClientGUI.ClientGUI;

import Const.*;

/**
 *
 * @author q530
 */
public class ClientMain {

    /**
     *
     * Metoda startujaca klienta
     * @param hostname
     * @param port
     */

    public static void initClient(String hostname, int port)
    {
        //klient
        Client client = new Client(hostname,port);
       // Client client = new Client("localhost",ServerConst.Port);
        ClientController clientController = new ClientController(client);

        //


        ClientListner clientListner = new ClientListner(clientController);
        new Thread(clientListner).start();
        //
        ClientGUI clientGUI = new ClientGUI(clientController);
        new Thread(clientGUI).start();

        


        
    }


    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        String hostname = "";
        int port = 0;

        if ( args.length < 1 ){
            hostname = "localhost";
        }
        else{
            hostname = args[0];
        }

        if ( args.length < 2 ){
            port = ServerConst.Port;
        }
        else{
            port = new Integer(args[1]);
        }

       initClient(hostname, port);
       
       System.out.println("Welcome LIFT user!");




    }

}
